package net.airuima.web.rest;

import io.swagger.v3.oas.annotations.tags.Tag;
import net.airuima.constant.Constants;
import net.airuima.domain.Demo;
import net.airuima.service.DemoService;
import net.airuima.web.ProtectBaseResource;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Copyright (C), 2017-2023, 武汉睿码智能科技有限公司
 * Resource
 *
 * @author ruima
 * @date 2024-02-06
 */
@Tag(name = "Resource")
@RestController
@RequestMapping("/api/demos")
public class DemoResource extends ProtectBaseResource<Demo> {

    private final Logger log = LoggerFactory.getLogger(DemoResource.class);

    private final DemoService demoService;

    public DemoResource(DemoService demoService) {
        this.demoService = demoService;
        this.mapUri = "/api/demos";
    }

    @Override
    public String getAuthorityDescription(String authority) {
        if (StringUtils.isBlank(authority)) {
            return "";
        } else if (authority.equals(this.entityName.toUpperCase() + Constants.AUTHORITY_READ)) {
            return "浏览";
        } else if (authority.equals(this.entityName.toUpperCase() + Constants.AUTHORITY_CREATE)) {
            return "新建";
        } else if (authority.equals(this.entityName.toUpperCase() + Constants.AUTHORITY_UPDATE)) {
            return "修改";
        } else if (authority.equals(this.entityName.toUpperCase() + Constants.AUTHORITY_DELETE)) {
            return "删除";
        } else if (authority.equals(this.entityName.toUpperCase() + Constants.AUTHORITY_IMPORT)) {
            return "导入";
        } else if (authority.equals(this.entityName.toUpperCase() + Constants.AUTHORITY_EXPORT)) {
            return "导出";
        }
        return "";
    }

}
